//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.goldhuman.Common;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public final class Statistic {
    public int m_max;
    public int m_min;
    public int m_cur;
    public int m_cnt;
    public int m_sum;
    private static HashMap<String, Statistic> m_map = new HashMap();

    private Statistic() {
        this.reset();
    }

    public void reset() {
        this.m_cur = 0;
        this.m_cnt = 0;
        this.m_sum = 0;
        this.m_max = 0;
        this.m_min = 0;
    }

    public void update(int __delta) {
        this.m_cur = __delta;
        ++this.m_cnt;
        this.m_sum += __delta;
        this.m_max = __delta > this.m_max ? __delta : this.m_max;
        this.m_min = this.m_min == 0 ? __delta : (__delta < this.m_min ? __delta : this.m_min);
    }

    public static Statistic GetInstance(String __name) {
        synchronized(m_map) {
            Statistic p = (Statistic)m_map.get(__name);
            if (p != null) {
                return p;
            } else {
                p = new Statistic();
                m_map.put(__name, p);
                return p;
            }
        }
    }

    public static boolean enumdefault(String __name, Statistic __stat) {
        System.out.println(__name);
        System.out.print(" MAX: " + __stat.m_max);
        System.out.print(" MIN: " + __stat.m_min);
        System.out.print(" CUR: " + __stat.m_cur);
        System.out.print(" CNT: " + __stat.m_cnt);
        System.out.println(" SUM: " + __stat.m_sum);
        return true;
    }

    public static void enumerate(StatCallBack cb) {
        synchronized(m_map) {
            Iterator<Map.Entry<String, Statistic>> it = m_map.entrySet().iterator();

            while(it.hasNext()) {
                Map.Entry<String, Statistic> entry = (Map.Entry)it.next();
                String name = (String)entry.getKey();
                Statistic stat = (Statistic)entry.getValue();
                cb.enumerate(name, stat);
            }

        }
    }

    public static synchronized void resetall() {
        synchronized(m_map) {
            Iterator<Map.Entry<String, Statistic>> it = m_map.entrySet().iterator();

            while(it.hasNext()) {
                Statistic p = (Statistic)((Map.Entry)it.next()).getValue();
                p.reset();
            }

        }
    }

    public interface StatCallBack {
        boolean enumerate(String var1, Statistic var2);
    }
}
